Skip to content

Run the page's own read after a write - #4589

Open
evanchooly wants to merge 1 commit into
audits-retire-rstfrom
audits-update-reads
Open

evanchooly wants to merge 1 commit into
audits-retire-rstfrom
audits-update-reads

Conversation

@evanchooly

Copy link
Copy Markdown
Member

Stacked on #4588 (audits-retire-rst). Step 4 of the parser retirement: option (c) for update results, "run the page's own read".

Problem

For a write, the runner's published check compared the page's printed result against the documents the update's own filter matched afterwards. That reading comes from the legacy harness, and pages don't work that way. When a page wants to show a write's effect, it runs a read of its own and prints that. The two kinds of example failed differently:

  • A page that shows its read got no runnable example. The read after the write reported AFTER_EARLIER_WRITE, and the write had no result. At docs e4b0c153 this covered all of the $merge and $out examples, which aggregate into a collection and then find() it, plus $currentDate's aggregation alternative.
  • A page whose update changes the field its filter matches on couldn't be checked. $[]'s negation example filters on grades: {$ne: 100} and raises the grades. The documents the filter matches afterwards aren't the collection the page prints. That case is excluded.

Change

  • Extraction: a find directly after a write in its section, with its printed result, joins the write's scenario as a second action, and the expectation names the find as its owner (expectedFor). The write must run one command and print nothing but, at most, an acknowledgement. The find gets no scenario of its own.
    • Pairing happens in the page-wide pass, so it works across a section's code and its input/output groups. That is the layout of the $merge and $out pages: a literalinclude followed by an io-code-block.
    • Pairing is refused when setup or a skipped write sits between the two.
    • The pair keeps the setup either side needs, such as the earlier inserts into the collection the find reads, in page order.
  • Inventory and scenario: the find is a READ block, and the scenario carries it as action.read: {collection, filter, projection?, sort?}. Any other modifier, such as limit, is a generation gap. The read is lowered together with the example's earlier code, so it sees the declarations made there.
  • Runner: for a case with a read, both sides run the read after the write, and its results replace the action's own in the behavior and published checks. An update with a read doesn't query its filter again; that query could fail after the update, for example when a $size filter's array has been unset.
  • Inventory at e4b0c153: 8 reads pair: six $merge/$out examples, $currentDate's aggregation alternative, and the read of the already-owned positional "Update with Multiple Array Matches". Unsupported examples drop from 112 to 104, and nothing else in the inventory changes.

Decisions to review

  1. Nothing new generates yet. Every newly paired example stops at a missing binding: $merge, $out, a pipeline update, a compound _id or a date literal. Those gaps belong to step 5 (bindings). The runner path is proven with its own fixtures: runner/readAfterUpdate passes with a read, runner/filterAfterUpdate (the same update with no read) fails the published check as before, and runner/readAfterUnset shows the filter query is skipped.
  2. Pages that print without showing a read keep the legacy reading, as agreed. That is most update pages, including $[]'s negation example, which stays excluded. Its reason now says what would lift it.
  3. Stricter marking of actions after writes, applied page-wide:
    • A write after a write now reports AFTER_EARLIER_WRITE too. Before, only reads did, so in input/output groups a second write ran as if the first had never happened.
    • A syntax template such as db.collection.updateOne( { <filter> } … ) no longer counts as a write.
    • Writes are keyed by section and by tab or selected-content branch. A write reaches its own branch and the branches nested in it, never a sibling tab, which is a separate example.
    • None of these changes alters the e4b0c153 inventory beyond the pairs listed above.
  4. Owned legacy cases are untouched. The positional owner's inventory entry now shows its read, but its frozen scenario doesn't carry one.

Testing

  • Audits suite: 438 tests, 0 failures, 4 skipped.
  • Core runner, generated, query.updates and aggregation.stages tests: 172 tests per mapper, run under Critter first and then reflection, with 0 failures.
  • A candidate of the tree reproduces it, apart from the manifest entries for the three new runner fixtures, which are committed.
  • Local review: three Codex rounds, which found 7 valid issues, all fixed with regression tests:
    • setup between a write and its read was dropped;
    • a write in one tab could pair with a read in another;
    • the filter query ran even when the case has a read;
    • the read lost the example's declarations;
    • a cross-collection read lost the inserts it inherits;
    • a write outside a tab missed a read inside it;
    • merged setup could land out of dependency order.

Self-reviewed only.

A find directly after a write in its section (an update, or a pipeline
ending in $merge or $out), with its printed result, now joins the
write's scenario as its read, across section code and input/output
groups. The inventory records it as a READ block, the scenario carries
it as action.read, and OperatorCaseRunner runs it on both sides after
the write, comparing its results instead of the filter's.

The page-wide pass also marks a write after a write, keys writes by
section and tab branch, and no longer counts a syntax template as a
write.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant